package com.leetcode.LC;

public class LC1309 {
    public String freqAlphabets(String s) {
        //由后往前遍历
        StringBuilder builder = new StringBuilder();
        for (int i = s.length()-1; i >= 0; i--) {
            if (s.charAt(i)!='#'){
                builder.append(toABC(s.charAt(i)+""));
            }else {
                builder.append(toABC(s.substring(i-2,i+1)));
                i=i-2;
            }
        }
        return builder.reverse().toString();

    }

    public char toABC(String s){
        if (!s.contains("#")){
            return (char) ('a'+(s.charAt(0)-'1'));
        }else {
            return (char) (Integer.valueOf(s.substring(0,2))-10+'j');
        }
    }

    public static void main(String[] args) {
        System.out.println(new LC1309().freqAlphabets("10#11#12"));
    }
}
